﻿@*use this for the fake AjaxOptions since ajax helpers were dropped in .net core*@
@model IPagedList<string>
    
@*import this so we get our HTML Helper*@
@using X.PagedList.Mvc.Core; 

@*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@
@using X.PagedList;

<ul>
    @foreach (var name in Model)
    {
        <li>@name</li>
    }
</ul>

@Html.PagedListPager(
    list: (IPagedList<string>)ViewBag.Names, 
    generatePageUrl: page => Url.Action("GetOnePageOfNames", new { page }), 
    options: PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(
        pagedListRenderOptions: new PagedListRenderOptions 
        { 
            MaximumPageNumbersToDisplay = 5, 
            DisplayPageCountAndCurrentLocation = true, 
            UlElementClasses = new[] 
            { 
                "pagination" 
            }, 
            ContainerDivClasses = new[] 
            { 
                "pagination-container" 
            } 
        },
        ajaxOptions: new AjaxOptions
        {
            HttpMethod = "GET", 
            UpdateTargetId = "nameListContainer" 
        })
)
